export function navigateTo(url : string) {
	uni.navigateTo({ url: url })
}

export function redirectTo(url : string) {
	uni.redirectTo({ url: url })
}

export function switchTab(url : string) {
	uni.switchTab({ url: url })
}

export function join(data : any[]) : null | string {
	if (data === undefined || data === null) {
		return null
	}
	return data.filter(v => v !== '' && v !== null).join(",")
}

export function split(data : string) : null | string[] {
	if (data === undefined || data === null) {
		return null
	}
	return data.split(",")
}

export function getStorage(key : string, defaultValue ?: any) {
	try {
		let value = uni.getStorageSync(key);
		if (value) {
			return value
		}
		return defaultValue === undefined ? null : defaultValue
	} catch (e) {
		// error
	}
}

export function setStorage(key : string, value : any) {
	try {
		uni.setStorageSync(key, value);
	} catch (e) {
		// error
	}
}